// 放置全局指令
import Vue from 'vue'
import store from '@/store'
// 封装和按钮权限相关的指令
Vue.directive('btn-auth', {
  // 所绑定的元素在执行dom时自动触发
  // el所绑定的元素，binding，指令的值
  inserted(el, binding) {
    const btnPerm = binding.value
    const userPermissions = store.state.user.userProfile.permissions
    if (!userPermissions.includes(btnPerm)) {
      el.remove()
    }
  }
})
